<script setup>
import {reactive} from 'vue'
import {login} from "../../api/userApi.js";

const loginForm = reactive({
  name: '',
  password: ''
})

const handleLogin = () => {
  login({
    name: loginForm.name,
    password: loginForm.password
  })
}
</script>

<template>
  <div class="Login">
    <div class="Login-Container">
      <div class="Login-Container-Title">系统登录</div>
      <el-form :model="loginForm" class="Login-Container-Form">
        <el-form-item>
          <el-input v-model="loginForm.name" placeholder="请输入用户名" prefix-icon="User"/>
        </el-form-item>
        <el-form-item>
          <el-input v-model="loginForm.password" type="password" placeholder="请输入密码" prefix-icon="Lock"
                    show-password/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" class="Login-Container-Form-Button" @click="handleLogin">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<style scoped lang="scss">
.Login {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background-color: #f0f2f5;

  &-Container {
    width: 400px;
    padding: 32px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);

    &-Title {
      font-size: 24px;
      font-weight: bold;
      text-align: center;
      margin-bottom: 24px;
      color: #303133;
    }

    &-Form {
      &-Button {
        width: 100%;
      }
    }
  }
}
</style>